package com.ithappy.oop;

public class TestOverride {
    public static void main(String[] args) {
        Horse h = new Horse();
        h.run();        //调用Horse中的run()而不是父类Vehicle中的run()
        h.getVehicle();     //Horse类中没有getVehicle()
        Plane b = new Plane();
        b.run();
    }
}

class Vehicle{      //交通工具类
    public void run(){
        System.out.println("跑...");
    }
    String a; Math b;
    public Vehicle getVehicle(){
        System.out.println("给你一个交通工具！");
        return null;
    }
}

class Horse extends Vehicle{
    @Override
    public void run(){
        System.out.println("得得得得....");
    }

    @Override
    public Horse getVehicle(){
        return new Horse();
    }
}

class Plane extends Vehicle{
    @Override
    public void run(){
        System.out.println("飞的贼快....");
    }
}

